package com.ylr.auth.domain;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @ClassName User
 * @Description TODO
 * @Author 11
 * @Date 2021/4/13 9:23
 * @Version 1.0
 */
@Data
@NoArgsConstructor
public class User implements UserDetails {

    private Long id;

    private String username;

    private String password;

    private Boolean enabled;

    private String clientId;

    private Collection<SimpleGrantedAuthority> authorities;

//    public User(UserDTO user) {
//        this.setId(user.getId());
//        this.setUsername(user.getUsername());
//        this.setPassword(AuthConstants.BCRYPT + user.getPassword());
//        this.setEnabled(Integer.valueOf(1).equals(user.getStatus()));
//        this.setClientId(user.getClientId());
//        if (CollectionUtil.isNotEmpty(user.getRoleIds())) {
//            authorities = new ArrayList<>();
//            user.getRoleIds().forEach(roleId -> authorities.add(new SimpleGrantedAuthority(String.valueOf(roleId))));
//        }
//    }


//    public User(AuthMemberDTO member){
//        this.setId(member.getId());
//        this.setUsername(member.getUsername());
//        this.setPassword(AuthConstants.BCRYPT + member.getPassword());
//        this.setEnabled( Integer.valueOf(1).equals(member.getStatus()));
//        this.setClientId(member.getClientId());
//    }


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return null;
    }

    @Override
    public String getUsername() {
        return null;
    }

    @Override
    public boolean isAccountNonExpired() {
        return false;
    }

    @Override
    public boolean isAccountNonLocked() {
        return false;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return false;
    }

    @Override
    public boolean isEnabled() {
        return false;
    }
}
